from scipy.optimize import leastsq
import numpy as np

def func(p,x):
    w0,w1=p
    f=w0+w1*x*x
    return f
def err_func(p,x,y):
    ret=func(p,x)-y
    return ret

p_init=np.random.randn(2)
x=np.array([1,2.5,3.5,4,5,7,8.5])
y=np.array([0.3,1.1,1.5,2.0,3.2,6.6,8.6])
parameters=leastsq(err_func,p_init,args=(x,y))
print(parameters[0])
